package com.sky.mapper.admin;

import com.github.pagehelper.Page;
import com.sky.annotation.AutoFill;
import com.sky.dto.DishPageQueryDTO;
import com.sky.enumeration.OperationType;
import com.sky.pojo.Dish;
import com.sky.vo.DishVO;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface DishMapper {

    /**
     * 根据分类id查询菜品数量
     * @param categoryId
     * @return
     */
    @Select("select count(id) from dish where category_id = #{categoryId}")
    Integer countByCategoryId(Long categoryId);


    @AutoFill(OperationType.INSERT)
    void save(Dish dish);

    Page<DishVO> page(DishPageQueryDTO dishPageQueryDTO);

    /**
     * 查询菜品的状态
     * @param ids
     * @param stutas
     * @return
     */
    Integer queryCountStatus(@Param("ids")List<Long> ids, @Param("stutas") Integer stutas);

    /**
     * 查询菜品是否包含在套餐中
     * @param ids
     */
    Integer queryCountByDishIds(List<Long> ids);

    void deletes(List<Long> ids);

    @Select("select * from dish where id = #{id}")
    DishVO findById(Integer id);

    void update(Dish dish);

    List<Dish> findBycategoryId(Dish dish);

    @Select("select * from dish where id = #{dishId}")
    DishVO getDishById(Long dishId);
}
